home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1116 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: "Aaron S. Binns" <asbinn@rstcorp.com>
  3. Newsgroups: comp.std.c++,comp.lang.c++
  4. Subject: 'const' binding to specifier in declaration list
  5. Followup-To: comp.std.c++
  6. Date: 16 Apr 1996 13:17:21 PDT
  7. Organization: Reliable Software Technologies
  8. Approved: austern@isolde.mti.sgi.com
  9. Message-ID: <3173B383.41C67EA6@rstcorp.com>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: Tue, 16 Apr 1996 10:49:39 -0400
  12. X-Mailer: Mozilla 2.0 (X11; I; SunOS 4.1.3 sun4c)
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMXQAUky4NqrwXLNJAQFGawIAnGEu49r8YllpssaySJ4ApM3h7931IOWY
  15.     b282FTnY9DXSCg73Ig4ld1JtRTcP6QxRy0LxskKvQmAN13wrD0Wl+A==
  16.     =wGec
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. [Moderator's note: This is crossposted to comp.std.c++ and
  20. comp.lang.c++, and followups have been set to comp.std.c++. mha]
  21.  
  22. I recently came across a piece of code that reads:
  23.  
  24. class A {
  25.   // contents of class A
  26. } a1, *a2, const *a3;
  27.  
  28.  
  29. This looks pretty bogus to me.  I thought that the 'const' applied
  30. to the elaborated specifier 'class A'.  If the 'const' qualifier is
  31. supposed to apply to the pointer in 'a3', then it should come _after_
  32. the '*'.
  33.  
  34. I think that either one of the two following was intended.
  35.  
  36. 1)
  37.  
  38. class A {
  39.   // contents of class A
  40. } a1, *a2, * const a3;
  41.  
  42.  
  43. 2)
  44.  
  45. class A {
  46.   // contents of class A
  47. } a1, *a2;
  48.  
  49. A const *a3;  // Or const A *a3;
  50.  
  51.  
  52. Is my interpretation of the binding of 'const' more or less correct?
  53.  
  54. BTW, this code _is_ accepted by the Microsoft VC/C++ v2.0 compiler.
  55.  
  56.  
  57. -- 
  58.  Aaron S. Binns                      Reliable Software Technologies Corp.
  59.                                      21515 Ridgetop Circle, Suite 250
  60.  asbinn@rstcorp.com                  Sterling, VA 20166
  61.                     http://www.rstcorp.com
  62. ---
  63. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  64.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  65.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  66.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  67.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  68. ]
  69.